# !/usr/bin/env python
# -*- coding: utf-8 -*-
# ///////////////////////////////////////////////////////////////
# @File    :   colorDopplerReportForm.py
# @Time    :   2024/08/29 17:15:49
# @Author  :   kai.luo
# @Version :   1.0.0
# @Desc    :  针对彩超报告
# ///////////////////////////////////////////////////////////////

# type: ignore
from paddleocr import PaddleOCR, PPStructure, draw_ocr
from moudles.ColorDopplerReportForm.commonLibrary.common import *
from moudles.ColorDopplerReportForm.sichuanModel.sichuan import Sichuan


class ColorDopplerReportForm(object):
    """
    医疗报告单
    Args:
        object (_type_): _description_
    """

    def __init__(self) -> None:
        # 初始化参数

        self.imagePath_reportFormData_dict = dict()  # 所有图片的数据字典

    def parserPPStructure(self, img_path):
        """
            # table_engine = PPStructure(show_log=True, use_gpu=False)
            # img = cv2.imread(img_path)
            # result = table_engine(img, True)
            # res = result[0].get('res', '')
            Args:
                img_path (_type_): _description_
        """

        ocr = PaddleOCR(use_gpu=False, use_angle_cls=True, lang="ch", det_model_dir="./model/det",
                        rec_model_dir="./model/rec/", cls_model_dir="./model/cls/")
        result = ocr.ocr(img_path, cls=True)

        # 判断该数据数据那个省市片区的报告单
        area = getImageArea(result[0])

        # 默认参数
        foortHeight = float(100)
        tipHeight = float(170)

        # 判断区域属性
        if area[0] == 'sichuan':
            sichuan_model = Sichuan()
            # print(f'result[0]---{result[0]}')
            image_data = sichuan_model.getSichuanImageData(result[0], foortHeight, tipHeight)

        return image_data
